package com.xinhe.web.service;

import com.xinhe.web.entity.ConfigurationDate;
import com.xinhe.web.entity.YunChaSeedAssetCount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
@Service

public class ConfigurationDateService {
    /*@Autowired
    private IConfigurationDateDao configurationDateDao;
    @Autowired
    private IMemberDao memberDao;
    @Autowired
    private IYunChaSeedAssetCountDao yunChaSeedAssetCountDao;

    public PageResult<ConfigurationDateView> pageConfigurationDate(ConfigurationDateQuery query) {
        Integer total = Integer.valueOf(0);
        if (0 < query.getLimit().intValue()) {
            total = this.configurationDateDao.countConfigurationDate(query);
        }
        List<ConfigurationDateView> views = null;
        if (0 < total.intValue() || 0 >= query.getLimit().intValue()) {
            views = this.configurationDateDao.pageConfigurationDate(query);
        }
        if (0 >= query.getLimit().intValue()) {
            if (null == views) {
                total = Integer.valueOf(0);
            } else {
                total = Integer.valueOf(views.size());
            }
        }
        return new PageResult(total, views);
    }




    @Transactional
    public BaseResult saveConfigurationDate(ConfigurationDateModel model) {
        if (null != model.getId()) {
            ConfigurationDate configurationDate = (ConfigurationDate)this.configurationDateDao.findById(model.getId());
            configurationDate.setNum(model.getNum());
            this.configurationDateDao.update((BaseEntityImpl)configurationDate);
        } else {
            ConfigurationDate configurationDate = new ConfigurationDate();
            configurationDate.setReleaseDate(model.getReleaseDate());
            configurationDate.setNum(model.getNum());
            this.configurationDateDao.save((BaseEntityImpl)configurationDate);


            List<Member> members = this.memberDao.findAll();
            for (Member member : members) {
                YunChaSeedAssetCount yunChaSeedAssetCount = new YunChaSeedAssetCount();
                yunChaSeedAssetCount.setConfigurationDateId(configurationDate.getId());
                yunChaSeedAssetCount.setBalance(BigDecimal.ZERO);
                yunChaSeedAssetCount.setUserId(member.getUserId());
                this.yunChaSeedAssetCountDao.save((BaseEntityImpl)yunChaSeedAssetCount);
            }
        }

        return new BaseResult();
    }


    protected IBaseDao<ConfigurationDate> getRealDao() {
        return (IBaseDao<ConfigurationDate>)this.configurationDateDao;
    }*/
}
